#ifndef PRIVATECHAT_H
#define PRIVATECHAT_H

#include <QWidget>
#include "../MeetingServer/messagepackage.h"
#include <QCloseEvent>

namespace Ui {
class PrivateChat;
}

class PrivateChat : public QWidget
{
    Q_OBJECT

public:
    explicit PrivateChat(QString sender, QString receiver, QWidget *parent = nullptr);
    ~PrivateChat();
protected:
    virtual void closeEvent(QCloseEvent *event) override;
private:
    void setMessageFormat(const QString &message, Qt::Alignment alignment);
    void setMessageTitleFormat(const QString &message, Qt::Alignment alignment);
    QStringList splitByLength(const QString &input, int length);

private slots:
    void on_ptn_send_clicked();

public slots:
    void onNewInfo(messagePackage pack);


private:
    Ui::PrivateChat *ui;
    QString sender;
    QString receiver;
    int hour = -1;
    int min = -1;

signals:
    void sendInfo(QString sender, QString receiver, QString info, QString time);
    void chatClose(QString receiver);
};

#endif // PRIVATECHAT_H
